package com.nuaa.shr.pls.algorithm;

import java.util.ArrayList;
import java.util.List;

import org.uma.jmetal.algorithm.Algorithm;
import org.uma.jmetal.problem.Problem;
import org.uma.jmetal.problem.multiobjective.GridManyObjectiveKnapsack;
import org.uma.jmetal.solution.GridPermutationSolution;


/**
 * 目的是减少时间复杂度，邻居比较多，现在解少？用格子选择的意义？
 * @author sevn
 *
 */
public class NrpGrEA implements Algorithm<List<GridPermutationSolution<Integer>>>{
	private int division;
	private double[] unitLen;
	private int populationSize;
	private Problem<GridPermutationSolution<Integer>> problem;
	private int maxIteration;
	
	private List<GridPermutationSolution<Integer>> workPopulation;
	private List<GridPermutationSolution<Integer>> externalPopulation;
	
	public NrpGrEA(Problem<GridPermutationSolution<Integer>> problem, 
			int maxIteration, int populationSize, int division){
		this.division = division;
		this.maxIteration = maxIteration;
		this.problem = problem;
		this.unitLen = new double[problem.getNumberOfObjectives()];
		this.populationSize = populationSize;
		
		workPopulation = new ArrayList<>();
		externalPopulation = new ArrayList<>();
	}

	@Override
	public String getName() {
		return "nrp-grea";
	}

	@Override
	public String getDescription() {
		return "nrp-grea";
	}

	@Override
	public void run() {
	}

	@Override
	public List<GridPermutationSolution<Integer>> getResult() {
		return externalPopulation;
	}
	
	public List<GridPermutationSolution<Integer>> createInitializePopulation(){
		List<GridPermutationSolution<Integer>> population = new ArrayList<>();
		for(int i = 0;i<populationSize;i++){
			GridPermutationSolution<Integer> solution = this.problem.createSolution();
			population.add(solution);
		}
		return population;
	}
}
